-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use guide-key with window-purpose [fixes #915] #1072
Conversation
Add window-purpose package, make guide-key use it as a backend instead of popwin. When window-purpose can't display guide-key buffer (e.g. if there are too many open windows), fallback to popwin. This fixes bug of guide-key buffer being too small when there are several windows open (issue #915).
This should work, but maybe someone else should also test that it works for him/her. |
Outch that's a lot of code for this :-)
I know this is a lot of questions but I want to understand your fix :-) |
No problem, it's good that you have questions. Just to be clear, window-purpose can do other stuff as well, but they're irrelevant for this fix. I'm only using some of its functionality here. Mainly Anyway, here are the answers for your questions:
Of course, there may be a way fix #915 without replacing popwin, but since you said this is a recurring issue with popup buffers, I propose to replace popwin with window-purpose, for guide-key. |
@syl20bnr are you still considering this PR? If you decided to reject it, tell me so I can delete it. |
My only concern is that larger guide-key windows could be annoying. I think ideally the behaviour would be to after a short time pop up a narrow window and then have it widen after a delay or keybind. Constantly having windows be blocked by massive guide-key popups could be annoying for some slower typists. |
@syl20bnr Let me briefly explain about Let's look at a more complicated example: you have 3 windows, one to the left and two to the right. The left window purpose is for Emacs Lisp buffer, the top right is for shell buffer and the bottom right is general purpose. In that case, whenever you open a new general purpose buffer like a help buffer or a diff buffer or a compilation buffer, it always displays at the bottom right. This mechanism is more sophisticated than the stock other window mechnism of stock Emacs that opens in any window it sees fits. Personally, I prefer this mechanism over popwin. Currently, |
@syl20bnr you can also have a look at this reddit thread for visual demonstration. |
Whoah cool @tuhdo thanks! There should be a layer for this. I am often annoyed by random help and magit buffers wrecking all my windows. Although what you are describing I don't think is a good fit for guide-key. guide-key I think should always be a new window on the side that dissapears, it shouldn't take over even a no-purpose window. But I think this might be a matter of personal preference. And as I think this PR shows window-purpose can be tuned to do exactly that, with 60 lines of additional code. |
@trishume It's the default behaviour of |
@bmag honestly I find the code very complicated for such a tweak, I feel that it should be something coded upstream in guide-key. BUT window-purpose as a great role to play in spacemacs, I'm not entirely sure for now but it could be as important as helm, use-package, projectile and the like. Let's find some usage pattern where window-purpose shines. The obvious first one I see is the REPL case, having the REPL always appearing by default in the same place is very appealing to me. Is it easy to move around the purposed window ? Say that the user wants the REPL below temporarily because it has a wide output. |
@syl20bnr here are some answers. It turned out to be a lengthy response, sorry about that. Admittedly this PR I proposed is a bit complicated for the issue it fixes. I mainly opened the PR so you can review and decide if you like it (which is how PRs are supposed to work, isn't it?). I'll check if guide-key's author thinks using window-purpose is a good idea. About use-cases for window-purpose, I think (and hope) it can do a lot of things with proper configuration and extensions. The main thing that window-purpose does is to maintain a robust window layout. That means that buffers are displayed in proper windows, as @tuhdo explained. Another thing you can do is quickly open a stored window layout ( Other than that, you can extend window-purpose to support other use-cases: (I tried to make it easy to extend)
And I'm sure more things can be done. In window-purpose I try to provide a good framework for extending Emacs' window behavior. About moving a window around, there isn't an easy way to do it with window-purpose. You could close the REPL window, create and select a new window at the bottom, then use (defun open-current-buffer-at-bottom ()
(interactive)
(select-window (purpose-display-at-bottom (current-buffer) nil))) There is one problem that you should know about, though. Right now there is a problem with using window-purpose and popwin together. When popwin opens a popup-window, it removes the purpose-dedicated state of all windows. I opened a (very simple) PR against popwin that fixes this problem three weeks ago, but didn't receive a response yet. @tuhdo I'm not sure I understood what you said about issue #1222. With window-purpose, when you open a buffer it should automatically open in the correct window, so you don't need |
@bmag yes, if |
Window purpose is a great layer, why was this PR closed? I thought it was still under discussion? Spacemacs still has a pain point with window popping and buffer management (ex. inconsistency in whether certain buffers pop up with focus or not, which buffers SPC-tab sometimes taking you to helm buffers, etc.). |
@sooheon There is another PR for this. I'm aware that spacemacs needs a good solution for layout consistency and Windows Purpose is well placed to fill the gap. |
Ah, I made a search and entered the wrong thread. Thanks :) |
Add window-purpose package, make guide-key use it as a backend instead
of popwin. When window-purpose can't display guide-key buffer (e.g. if
there are too many open windows), fallback to popwin.
This fixes bug of guide-key buffer being too small when there are
several windows open (issue #915).